#include "BreathingLamp.h"
#include <Arduino.h>

BreathingLamp::BreathingLamp(uint32_t pin)
    : BaseLamp(pin), _on(5), _level(0)
{
    _speed = 50;
    digitalWrite(pin, LOW);
}

BreathingLamp::~BreathingLamp()
{
}

bool BreathingLamp::Run()
{
    HT_BEGIN();

    while (1)
    {
        // _ex_timer.start(_speed);
        // PT_WAIT_UNTIL(_ex_timer.expired());
        HT_DELAY(_speed);
        _level += _on;
        analogWrite(_pin, _level);
        if (_level >= 255)
        {
            _on = -5;
        }
        else if (_level <= 0)
        {
            _on = 5;
        }
    }
    HT_END();
}